package com.task.www.constant;

import com.task.www.dao.UserData;
import com.task.www.po.Food;
import com.task.www.util.Clear;

import java.util.ArrayList;

public class ShowUser {
    private UserData data = new UserData();

    public void user(int ids) {
        Clear.clear();
        int monney = data.selectmonney(ids);
        System.out.println("你的余额：" + monney);
        System.out.println("\n请选择如下操作：\n【1】浏览店铺\n【2】充值\n【3】查看订单\n【4】退出");
    }

    public void merchants(ArrayList<String> merchants) {
        Clear.clear();
        System.out.println("店家列表：\n");
        for (int i = 0; i < merchants.size(); i++) {
            System.out.println("\n【" + (i+2)/2 + "】" + "店名：" + merchants.get(i++));
            System.out.println("介绍；" + merchants.get(i));
        if (i == merchants.size() - 1) {
            System.out.println("\n【" + (i+3)/2 + "】" + "返回上一页面");
            }
        }
    }

    //店家页面
    public void merchantinterface(ArrayList<String> merchant , ArrayList<Integer> coupons , ArrayList<Food> foods){
        Clear.clear();
        System.out.println("店名：" + merchant.get(0));
        System.out.println("介绍；" + merchant.get(1));
        System.out.print("\n优惠券：");
        for (int i = 0; i < coupons.size(); i++) {
            if(i%2==0){
                System.out.print("\n满" + coupons.get(i));
            }else{
                System.out.print("减" + coupons.get(i) + "\t");
            }
        }
        System.out.println("\n\n菜单：");
        for (Food food : foods) {
            System.out.println(food.getName() + "\n￥" + food.getPrice());
            System.out.println();
        }
        System.out.println("请选择如下选项；\n【1】领取该店优惠券\n【2】进入菜单页面\n【3】返回上一页面");
    }

    //菜单页面
    public void foods(ArrayList<Food> foods){
        Clear.clear();
        int i = 0;
        for (; i < foods.size(); i++) {
            System.out.println("【" + (i+1) + "】；" + foods.get(i).getName());
            System.out.println("￥"+foods.get(i).getPrice());
            System.out.println(foods.get(i).getIntroduce());
            System.out.println();
        }
        System.out.println("【" + (i+1) + "】；" + "返回上一页面");
        System.out.println();
        System.out.println("请根据编号进行操作");
    }

    //买菜页面
    public void foodbuy(ArrayList<String> food){
        Clear.clear();
        System.out.println("菜名：" + food.get(0));
        System.out.println("价格：" + food.get(1) + "￥");
        System.out.println("介绍：" + food.get(2));
        System.out.println("商家的评论：" + food.get(3));
        System.out.println("用户的评论：" );
        for (int i = 4; i < food.size(); i++) {
            System.out.print("用户" + food.get(i++) + "：");
            System.out.println(food.get(i));
        }
        System.out.println("\n请选择如下操作：\n【1】下单\n【2】评论\n【3】返回上一页面");
    }

    //下单页面
    public void buy(int buyup,int buydown){
        Clear.clear();
        System.out.println("使用优惠券前：" + buyup);
        System.out.println("使用优惠券后：" + buydown);
        System.out.println("\n请选择如下操作\n【1】使用优惠券购买\n【2】不用优惠券购买\n【3】返回上一页面");
    }

    //查看订单
    public void order(ArrayList<String> order){
        for (int i = 0; i < order.size(); i++) {
            if(i%2==0){
                System.out.print(order.get(i) + "\t");
            }else{
                if(order.get(i).equals("true")){
                    System.out.println("商家已接单");
                    System.out.println();
                }
                if(order.get(i).equals("false")){
                    System.out.println("商家未接单");
                    System.out.println();
                }
            }
        }
        System.out.println("请输入如何内容以跳回主页面");
    }

}
